package com.geekchique.runningbuddy.view;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.geekchique.runningbuddy.activity.Home;
import com.geekchique.runningbuddy.activity.MapOfJog;
import com.geekchique.runningbuddy.activity.PastJogs;
import com.geekchique.runningbuddy.activity.StopClock;
import com.geekchique.runningbuddy.activity.Today;
import com.geekchique.runningbuddy.provider.ActivityID;

public class HomeView  extends LinearLayout {

	private Home activity;

	public HomeView(Home home, Button gotoStopClock, Button gotoToday, Button gotoPastJogs, Button gotoMap) {
		super(home);
		
		this.activity = home;
		gotoStopClock.setOnClickListener(gotoStopClockListener);
        gotoToday.setOnClickListener(gotoTodayListener);
        gotoPastJogs.setOnClickListener(gotoPastJogsListener);
        gotoMap.setOnClickListener(gotoJogMapListener);
	}
	
	private void switchToStopClock() {
	      Intent i = new Intent(activity, StopClock.class);
	      activity.startSubActivity(i, ActivityID.STOPCLOCK);	
	}

	private void switchToToday() {
	    Intent i = new Intent(activity, Today.class);
	    activity.startSubActivity(i, ActivityID.TODAYJOGS);	
	}

	private void switchToPastJogs() {
	    Intent i = new Intent(activity, PastJogs.class);
	    activity.startSubActivity(i, ActivityID.PASTJOGS);
	}
	
	private void switchToMapOfJog() {
		Intent i = new Intent(activity, MapOfJog.class);
		activity.startSubActivity(i, ActivityID.JOGMAP);
	}

	private OnClickListener gotoJogMapListener = new OnClickListener()
	{
	  	public void onClick(View v)
	      {
	  		switchToMapOfJog();
	      }
	};
	
	private OnClickListener gotoStopClockListener = new OnClickListener()
	{
		public void onClick(View v)
		{
			switchToStopClock();
		}
	};
  
	private OnClickListener gotoTodayListener = new OnClickListener()
	{
	  	public void onClick(View v)
	      {
	  		switchToToday();
	      }
	};
  
	private OnClickListener gotoPastJogsListener = new OnClickListener()
	{
	  	public void onClick(View v)
	  	{
	  		switchToPastJogs();
	  	}
	};

}
